import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import EffectScatter
from pyecharts.faker import Faker
from pyecharts.globals import SymbolType
class Bookcatter:
    def __init__(self):
        # 1：数据采集
        #书籍名称	借阅人姓名	班级	借阅日期	借阅天数
        bookrecords = pd.read_csv("data/书籍借阅记录.csv", encoding='utf-8-sig')
        bookcount = bookrecords['书籍名称'].groupby(bookrecords['借阅人姓名']).count()
        print(bookcount)
        # 3:数据可视化
        x_data = list(bookcount.keys())
        y_data = list(bookcount)
        c = (
            EffectScatter(init_opts=opts.InitOpts(bg_color='rgba(255,250,205,0.2)',
                                width='100%',
                                height='100%',
                                ))
                .add_xaxis(x_data)
                .add_yaxis("", y_data, symbol=SymbolType.ARROW)
                .set_global_opts(title_opts=opts.TitleOpts(title=""))
                .render("templates/effectscatter_symbol.html")
        )
Bookcatter()
